package prime_number;

import java.io.FileInputStream;
import java.io.FileOutputStream;

public class Main {
    public static void main(String[] args) throws Exception {
        FileOutputStream fileOutputStream = new FileOutputStream("src/prime_number/prime.dat");
        int a = 2;

        while(a <= 100) {
            int c = 0;
            for (int b = 2; b < a; b++) {
                if (a % b != 0) {
                    c++;
                }
            }

            if (c == a - 2) {
                fileOutputStream.write(a);
            }
            a++;
        }
        fileOutputStream.close();

        FileInputStream fileInputStream = new FileInputStream("src/prime_number/prime.dat");
        int count = fileInputStream.read();
        while(count != -1){
            System.out.print((int)count + " ");
            count = fileInputStream.read();
        }

        fileInputStream.close();
    }
}
